/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.teama;

/**
 *
 * @author bamidei
 */
public class User{
    private int    idUser = 0;  /* match up with auto index in database - needed for select */
    private String emailAddress = null;
    private String lastName = null;
    private String firstName = null;
    private int sortPref = UserDA.getDefaultSortPref();
    
    /* specific for instantiation out of database */
    public User(int idUser, String emailAddress, String lastName, String firstName, int sortPref){
        this.idUser = idUser;
        this.emailAddress = emailAddress;
        this.lastName = lastName;
        this.firstName = firstName;
        this.sortPref = sortPref;
    }
    
    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public void setSortPref(int sortPref) {
        this.sortPref = sortPref;
    }

    public String getEmailAddress() {
        return emailAddress;
    }
    
    public int getIdUser(){
        return this.idUser;
    }
    
    public String getLastName() {
        return lastName;
    }
    public String getFirstName() {
        return firstName;
    }
    
    public int getSortPreference() {
        return sortPref;
    }
    
    public boolean validate() {
        String em = getEmailAddress();
        
        assert(em != null);
        
        /* Various ways to validate email...add to these statements more. */
        if(em.length() < 3) return false;
        if(!em.contains("@")) return false;
        return true;
    }
}
